﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Compression;

namespace Sinacor.OMM.HealthMonitor.Entity.Common
{
    public static class StreamExtension
    {
        public static void Copy(this Stream s, Stream destination)
        {
            Copy(s, destination, s.Length);
        }

        public static void Copy(this DeflateStream s, Stream destination)
        {
            Copy(s, destination, s.BaseStream.Length);
        }

        private static void Copy(Stream source, Stream destination, long length)
        {
            byte[] readBuffer = new byte[length];
            int numRead = Convert.ToInt32(length);
            while ((numRead = source.Read(readBuffer, 0, numRead)) != 0)
                destination.Write(readBuffer, 0, numRead);
        }
    }
}
